package com.atguigu.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.atguigu.dao.CommunityDao;
import com.atguigu.dao.DictDao;
import com.atguigu.entity.Community;
import com.atguigu.entity.Dict;
import com.atguigu.service.CommunityService;
import com.base.BaseDao;
import com.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;
import java.util.List;

@Service
public class CommunityServiceImpl extends BaseServiceImpl<Community> implements CommunityService {
    @Autowired
    private CommunityDao communityDao;
    @Autowired
    private DictDao dictDao;

    @Override
    protected BaseDao<Community> getEntityDao() {
        return communityDao;
    }
    @Override
    public List<Community> findAll() {
        List<Community> list = communityDao.findAll();
        return list;
    }
    @Override
    public Community getById(Serializable id) {
        Community community = super.getById(id);
        Dict dict = this.dictDao.getById(community.getAreaId());
        community.setAreaName(dict.getName());
        String plateName = this.dictDao.getNameById(community.getPlateId());
        community.setPlateName(plateName);
        return community;
    }
}
